var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/help/DedicatedHelp.tsx
var DedicatedHelp_exports = {};
__export(DedicatedHelp_exports, {
  DedicatedHelp: () => DedicatedHelp,
  default: () => DedicatedHelp_default
});
module.exports = __toCommonJS(DedicatedHelp_exports);
var import_react = __toESM(require("react"));
var import_functionalComponent = require("../../functionalComponent");
var import_util = require("../../util");
var import_common = require("./common");
var { Flex, Slider } = import_util.Layout;
var { Header, Footer, MultipleButtons } = import_functionalComponent.BaseHelp;
var tableProps = {
  rowSelected: false,
  rowChecked: true,
  cache: false,
  headerMenu: false,
  style: { borderStyle: "solid", borderColor: "var(--border-color-split, #f0f0f0)", borderWidth: 1 }
};
function HelpContent() {
  const {
    request,
    ok,
    contentParams: { getFieldValue, columns, helpTitle, helpId, selectedArray, multiple, footer },
    randomKey
  } = (0, import_react.useContext)(import_functionalComponent.HelpContext);
  const btnRef = (0, import_react.useRef)();
  const formRef = (0, import_util.useApi)();
  const [activeKey, setActiveKey] = (0, import_react.useState)("0");
  const rightTable = (0, import_react.useRef)();
  const getTable = () => import_util.iup.compIns[`${helpId}_${randomKey}_${activeKey}`].getApi();
  const getResult = () => {
    if (multiple) {
      const result = rightTable.current.getApi().getRows().map((r) => ({
        value: getFieldValue(r),
        label: getFieldValue(r, "label"),
        origin: { ...r }
      }));
      return result.length > 0 ? result : void 0;
    } else {
      const value = getTable().getSelectedData()[0];
      if (value) {
        return { value: getFieldValue(value), label: getFieldValue(value, "label"), origin: { ...value } };
      }
      return void 0;
    }
  };
  const toRight = (values) => {
    if (multiple) {
      btnRef.current.toRight(values);
    } else {
      ok(getResult());
    }
  };
  tableProps.checkbox = multiple ? "checked" : false;
  tableProps.rowSelected = !multiple;
  tableProps.rowChecked = multiple;
  const renderTable = (index) => {
    return /* @__PURE__ */ import_react.default.createElement(
      import_functionalComponent.Table,
      {
        ...tableProps,
        style: { ...tableProps.style },
        id: `${helpId}_${randomKey}_${index}`,
        columns,
        onRow: (rowIndex, table) => ({
          onDoubleClick: () => toRight([table.getRow(rowIndex)])
        }),
        request
      }
    );
  };
  return /* @__PURE__ */ import_react.default.createElement(import_util.Layout, null, /* @__PURE__ */ import_react.default.createElement(Header, { title: helpTitle || "预警方案帮助" }), /* @__PURE__ */ import_react.default.createElement(Flex, { direction: "row", style: { padding: "16px 16px 0 16px" } }, /* @__PURE__ */ import_react.default.createElement(import_util.Layout.Flex, { style: { paddingBottom: multiple ? 32 : 0 } }, renderTable(0)), multiple && /* @__PURE__ */ import_react.default.createElement(
    MultipleButtons,
    {
      getRowKey: getFieldValue,
      outRef: btnRef,
      getActiveTable: getTable,
      getResultTable: () => rightTable.current.getApi()
    }
  ), multiple && /* @__PURE__ */ import_react.default.createElement(import_util.Layout.Flex, { style: { paddingTop: 7, paddingBottom: activeKey === "0" ? 32 : 0 } }, /* @__PURE__ */ import_react.default.createElement(
    import_functionalComponent.Table,
    {
      ...tableProps,
      columns,
      dataSource: selectedArray,
      ref: rightTable,
      onRow: (rowIndex) => ({
        onDoubleClick: () => btnRef.current.toLeft(rowIndex)
      })
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      id: `${helpId}_${randomKey}_pagination`,
      style: {
        position: "absolute",
        left: 221,
        right: 5,
        ...(0, import_util.borderStyle)(["left", "right", "bottom"]),
        paddingLeft: 10
      }
    }
  ))), /* @__PURE__ */ import_react.default.createElement(Footer, { getResult }, footer && /* @__PURE__ */ import_react.default.createElement("span", { style: { flex: 1, width: 0 }, children: footer })));
}
var DedicatedHelp = (0, import_util.compHoc)((props) => {
  const cacheHelpInfo = (0, import_react.useRef)({ data: null, p: null });
  const {
    valueField = "schemeCode",
    labelField = "schemeName",
    displayField,
    userCodeField,
    clientSqlFilter,
    title,
    multiple = false,
    modalProps,
    footer,
    customRequest,
    params = {},
    columns,
    onBeforeOpen,
    ...others
  } = props;
  const otherProps = others;
  otherProps.onBeforeOpen = (0, import_util.useRefCallback)(async () => {
    const [status, helpInfo] = await (0, import_common.getHelpBeforeOpen)({ onBeforeOpen, cacheHelpInfo });
    if (import_util.iup.isObject(helpInfo)) {
      return helpInfo;
    }
    return status;
  });
  otherProps.request = (0, import_util.useRefCallback)(async ({ pageIndex, pageSize }) => {
    if (customRequest) {
      return await customRequest(params);
    }
    return import_util.iup.request.body({
      url: "/iup-early-warning/warnSchemeDefine/listByIndicators",
      data: params
    }).then((res) => {
      if ((res == null ? void 0 : res.code) === 0) {
        return res == null ? void 0 : res.data;
      } else {
        return { list: [], total: 0 };
      }
    });
  });
  otherProps.valueField = valueField;
  otherProps.userCodeField = userCodeField;
  otherProps.labelField = labelField || displayField;
  otherProps.contentParams = {
    footer,
    multiple,
    valueField,
    labelField: otherProps.labelField,
    columns: columns ?? [
      { dataIndex: "schemeCode", title: "预警编码" },
      { dataIndex: "schemeName", title: "预警名称", tooltip: true },
      {
        dataIndex: "sharePolicy",
        title: "共享策略",
        render: ({ row }) => {
          const { sharePolicy } = row;
          const policyMaps = {
            0: "集团共享",
            1: "单元共享",
            2: "组织私有"
          };
          return policyMaps[sharePolicy];
        }
      },
      { dataIndex: "tenantName", title: "所属单元", tooltip: true },
      { dataIndex: "insertOrgName", title: "所属组织", tooltip: true }
    ]
  };
  if (title) {
    otherProps.contentParams.helpTitle = title;
  }
  const { width, height } = (0, import_util.getGlobalConfig)().default.helpConfig;
  return /* @__PURE__ */ import_react.default.createElement(
    import_functionalComponent.BaseHelp,
    {
      ...otherProps,
      modal: true,
      helpContent: HelpContent,
      multiple,
      modalProps: { width, height, ...modalProps }
    }
  );
}, "DedicatedHelp");
var DedicatedHelp_default = DedicatedHelp;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  DedicatedHelp
});
